package client.jobs.adventurer;

import client.*;
import client.anticheat.CheatTracker;
import client.anticheat.CheatingOffense;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import client.jobs.JobHandler;
import client.jobs.job.MapleJob;
import client.jobs.job.MapleJobCode;
import client.skills.Skill;
import client.skills.SkillFactory;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import constants.GameConstants;
import constants.JobConstants;
import constants.ServerConstants;
import constants.SkillConstants;
import constants.skills.*;
import handling.channel.handler.AttackInfo;
import handling.world.WorldBroadcastService;
import handling.world.party.MaplePartyCharacter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import server.AutobanManager;
import server.MapleStatEffect;
import server.MapleStatEffectFactory;
import server.MapleStatInfo;
import server.life.Element;
import server.life.MapleMonster;
import server.life.MapleMonsterStats;
import server.maps.MapleMist;
import server.maps.pvp.MaplePvp;
import tools.*;
import tools.data.input.LittleEndianAccessor;
import tools.data.output.MaplePacketLittleEndianWriter;
import tools.packet.ForcePacket;

import java.awt.*;
import java.util.*;

/**
 * @Author dwang
 * @Description 飞侠职业群技能控制
 * @create 2022/5/17 14:35
 * @Modified By:
 */
public class ThiefHandler extends JobHandler {

    private static final Logger log = LogManager.getLogger(ThiefHandler.class.getName());


    @Override
    public void parseCloseJobSkip1(AttackInfo ai, LittleEndianAccessor lea, boolean energy) {
        switch (ai.skillId) {
            case 双刀.阿修罗:
                lea.skip(4);
                break;
            default:
                if (SkillConstants.isInflationSkill(ai.skillId) || energy) {
                    lea.skip(4);
                } else {
                    lea.skip(5);
                }
                break;
        }
    }

    @Override
    public void parseCloseAICharge(MapleCharacter chr, AttackInfo ai, LittleEndianAccessor lea, boolean energy, Skill skill) {
        switch (ai.skillId) {
            case 侠盗.潜影杀机:
            case 双刀.终极斩:
                ai.charge = lea.readInt();
                break;
            default:
                ai.charge = !energy && skill != null && skill.isChargeSkill() && ai.skillId != 双刀.阿修罗 ? lea.readInt() : 0;
                break;
        }

    }

    @Override
    public void parseCloseJobSkip2(MapleCharacter chr, AttackInfo ai, LittleEndianAccessor lea) {
        int skillid = ai.skillId;
        switch (skillid) {
            default:
        }
    }

    @Override
    public void parseCloseJobSkip3(MapleCharacter chr, AttackInfo ai, LittleEndianAccessor lea, boolean energy, Skill skill) {
        //四个00
        lea.skip(4);
        if (!energy && lea.readInt() > 0) {
            lea.skip(1);
        }
    }

    @Override
    public int applySkillMobCount(MapleCharacter player, AttackInfo attack, MapleStatEffect effect) {
        int mobCount = effect.getMobCount();
        return mobCount;
    }

    @Override
    public int getSkillAttackCount(MapleStatEffect effect, MapleCharacter player, AttackInfo attack) {
        Map<MapleStatInfo, Integer> info = effect.getInfo();
        int sourceid = effect.getSourceid();
        int attackCount = info.get(MapleStatInfo.attackCount) + player.getStat().getAttackCount(sourceid);
        return attackCount;
    }

    @Override
    public long beforeAttack(MapleCharacter player, AttackInfo attack, MapleMonster monster, int visProjectile) {
        if (JobConstants.is隐士(player.getJob())) {
            boolean isUseSkillEffect = true;
            if (player.isBuffFrom(MapleBuffStat.刺客标记, SkillFactory.getSkill(隐士.刺客标记))) {

                Skill mskill = null;
                int mskillid = 0;
                int mskillevel = 0;
                MapleStatEffect effectSkill = null;

                if (player.getSkillLevel(SkillFactory.getSkill(隐士.刺客标记)) > 0) {
                    mskillid = 隐士.刺客标记;
                    mskill = SkillFactory.getSkill(隐士.刺客标记);
                    mskillevel = player.getSkillLevel(SkillFactory.getSkill(隐士.隐士标记));
                }

                if (player.getSkillLevel(SkillFactory.getSkill(隐士.隐士标记)) > 0) {
                    mskillid = 隐士.隐士标记;
                    mskill = SkillFactory.getSkill(隐士.隐士标记);
                    mskillevel = player.getSkillLevel(SkillFactory.getSkill(隐士.隐士标记));
                }
                for (MonsterStatusEffect s : monster.getAllBuffs()) {
                    //检测该怪物是否存在刺客标记
                    if (s.getSkill() == mskillid) {
                        if (JobConstants.is隐士(player.getJob())) {
                            if (attack.skillId != 0 && attack.skillId != 隐士.刺客标记_飞镖 && attack.skillId != 隐士.隐士标记_飞镖 && visProjectile > 0) {
                                isUseSkillEffect = false;
                                player.handleAssassinStack(monster, visProjectile);
                                //对其怪物取消标记
                                monster.cancelSingleStatus(s);
                                //monster.cancelSingleStatus(new MonsterStatusEffect(MonsterStatus.中毒, effectSkill.getDOT(), mskillid, null, false));
                            }
                        }
                    }
                }

                // 添加刺客标记效果
                if (isUseSkillEffect) {
                    if (mskill != null) {
                        effectSkill = mskill.getEffect(mskillevel);
                    }
                    if (effectSkill != null) {
                        if (attack.skillId != 0 && attack.skillId != 隐士.刺客标记_飞镖 && attack.skillId != 隐士.隐士标记_飞镖 && visProjectile > 0) {
                            if (effectSkill.makeChanceResult()) {
                                monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.MOB_STAT_Poison, effectSkill.getDOT(), mskillid, null, false, effectSkill.getDOTStack()), true, effectSkill.getDuration(), true, effectSkill);
                            }
                        }
                    }
                }
            }
            return 0;
        }
        return 0;
    }


    @Override
    public void onAttack(final MapleCharacter player, final MapleMonster monster, int skillid, long totDamage, AttackPair oned) {
        final PlayerStats stats = player.getStat();
        final PlayerSpecialStats specialStats = player.getSpecialStat();
        int job = player.getJob();
        int moboid = monster.getObjectId();
        long maxhp = monster.getMobMaxHp();
        Point point = monster.getPosition();
        /*参数传递到当前怪物的伤害*/
        player.setTotDamageToMob(totDamage);

        //------------------------------------------------- 针对职业控制
        //
        //
        if (JobConstants.is侠盗(job)) {
            int s = player.getTotalSkillLevel(侠盗.名流爆击) > 0 ? 侠盗.名流爆击 : 侠盗.暴击蓄能;
            Optional.ofNullable(SkillFactory.getSkill(s)).ifPresent(skill -> {
                final MapleStatEffect eff = skill.getEffect(player.getTotalSkillLevel(skill));
                if (player.getTotalSkillLevel(skill) > 0) {
                    int critical = Math.min(100, (eff.getX() + player.getCriticalGrowth()));
                    player.setCriticalGrowth((critical > 0 && critical <= 100) ? critical : 0);
                    eff.applyTo(player);
                }
            });

            /* 在一定时间内攻击敌人时掉落金币。技能等级越高，掉落的金币越多。使用一次会激活，再使用一次就会关闭效果的#cON/OFF技能 */
            if (player.getBuffedValue(MapleBuffStat.敛财术) != null) {
                /* 以下技能在攻击时，将会掉落金币 */
                switch (skillid) {
                    case 0:
                    case 飞侠.二连击:
                    case 侠盗.回旋斩:
                    case 侠盗.炼狱:
                    case 侠盗.刀刃之舞:
                    case 侠盗.突然袭击:
                    case 侠盗.一出双击:
                        int maxmeso = player.getBuffedValue(MapleBuffStat.敛财术);
                        Optional.ofNullable(SkillFactory.getSkill(侠盗.敛财术)).ifPresent(skill1 -> {
                            MapleStatEffect effect = skill1.getEffect(player.getTotalSkillLevel(侠盗.敛财术));
                            for (Pair<Long, Boolean> eachde : oned.attack) {
                                long num = eachde.left;
                                if (player.getStat().pickRate >= 100 || Randomizer.nextInt(99) < player.getStat().pickRate) {
                                    player.getMap().spawnMesoDrop(Math.min((int) Math.max(((double) num / (double) 20000) * maxmeso, 1), maxmeso), new Point((int) (monster.getTruePosition().getX() + Randomizer.nextInt(100) - 50), (int) (monster.getTruePosition().getY())), monster, player, false, (byte) 0);
                                    player.setBuffedValue(MapleBuffStat.敛财术, Math.min(effect.getY(), player.getBuffedIntValue(MapleBuffStat.敛财术) + 1));
                                    effect.applyTo(player, true);
                                }
                            }
                        });
                        break;
                }
            }
            player.handleKillSpreeGain();

        }

        //------------------------------------------------- 针对技能控制
        //
        //
        if (skillid > 0) {
            Optional.ofNullable(SkillFactory.getSkill(skillid)).ifPresent(skil -> {
                MapleStatEffect effect = skil.getEffect(player.getTotalSkillLevel(skil));
                switch (skillid) {
                    //伊卡尔特的吸血 - 伊卡尔特召唤吸血鬼后，对多个敌人造成4连击，并吸收部分伤害恢复HP。一次不可吸收超过角色最大HP1/2以上，也不可超过怪物的最大HP。特定等级提升时，技能等级可以提升1。
                    case 1078: {
                        if (totDamage > 0) {
                            player.addHP(((int) Math.min(maxhp, Math.min(((int) ((double) totDamage * (double) effect.getX() / 100.0)), stats.getMaxHp() / 2))));
                        }
                        break;
                    }
                    case 双刀.流云斩:
                    case 双刀.双刀风暴:
                    case 双刀.血雨腥风:
                    case 双刀.悬浮地刺:
                    case 双刀.暗影飞跃斩:
                    case 双刀.终极斩:
                    case 双刀.暴怒刀阵:
                    case 双刀.地狱锁链:
                    case 双刀.幽灵一击:
                    case 飞侠.二连击:
                    case 飞侠.双飞斩:
                    case 侠盗.回旋斩:
                    case 侠盗.炼狱:
                    case 侠盗.刀刃之舞:
                    case 侠盗.暗杀:
                    case 侠盗.一出双击:
                    case 侠盗.突然袭击:
                    case 隐士.爆裂飞镖:
                    case 隐士.风之护符:
                    case 隐士.三连环光击破:
                    case 隐士.影子分裂:
                    case 隐士.四连镖: {
                        int[] skills = {侠盗.武器用毒液, 隐士.武器用毒液, 双刀.武器用毒液};
                        int[] skillss = {侠盗.致命毒液, 隐士.致命毒液, 双刀.致命毒液};
                        int skillS = 0;
                        for (int i : skillss) {
                            if (player.getTotalSkillLevel(i) > 0) {
                                skillS = i;
                                break;
                            }
                        }
                        for (int i : skills) {
                            int finalSkillS = skillS;
                            Skill skill = SkillFactory.getSkill(i);
                            if (player.getTotalSkillLevel(skill) > 0) {
                                MapleStatEffect venomEffect = skill.getEffect(player.getTotalSkillLevel(skill));
                                if (player.getTotalSkillLevel(finalSkillS) > 0) {//致命毒液
                                    Optional.ofNullable(SkillFactory.getSkill(finalSkillS)).ifPresent(skill1 -> {
                                        MapleStatEffect effect1 = skill1.getEffect(player.getTotalSkillLevel(skill1));
                                        int szie = 0;
                                        for (MonsterStatusEffect s : monster.getAllBuffs()) {
                                            if (s.getSkill() == finalSkillS) {
                                                szie++;
                                            }
                                        }

                                        if (effect1.makeChanceResult()) {
                                            if (szie < effect1.getDOTStack() + 1) {
                                                monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.MOB_STAT_Poison, effect1.getDOT(), finalSkillS, null, false), true, effect1.getDuration(), true, effect1);
                                            }
                                        }
                                    });
                                } else {
                                    if (venomEffect.makeChanceResult()) {
                                        monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.MOB_STAT_Poison, 1, i, null, false), true, venomEffect.getDuration(), true, venomEffect);
                                    }
                                }
                                break;
                            }
                        }
                        break;
                    }
                    case 侠盗.神通术: { // 神通术
                        monster.handleSteal(player);
                        break;
                    }
                    default:
                        break;
                }
            });
        }

        //------------------------------------------------- 针对状态控制
        //
        //
        if (player.getBuffedValue(MapleBuffStat.额外回避) != null) {
            MapleStatEffect eff = player.getStatForBuff(MapleBuffStat.额外回避);
            if ((eff != null) && (eff.makeChanceResult())) {
                monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.MOB_STAT_Speed, eff.getX(), 3121007, null, false, 0), false, eff.getY() * 1000, true, eff);
            }
        }
    }




    @Override
    public void afterAttackHandler(MapleCharacter player, int mobCount, int skillid, boolean isCritDamage) {
        final PlayerSpecialStats specialStats = player.getSpecialStat();
        int job = player.getJob();
        // 控制职业
        switch (job) {
            case MapleJobCode.主教:
                // 消耗魔量26，最多以80%的伤害攻击6个敌人7次，或者使包括自己在内的队员恢复最大血量的10%。
                if (skillid == 主教.光芒飞箭 && player.getParty() != null) {
                    for (MaplePartyCharacter pc : player.getParty().getMembers()) {
                        if (pc != null && pc.getMapid() == player.getMapId() && pc.getChannel() == player.getClient().getChannel()) {
                            MapleCharacter other = player.getClient().getChannelServer().getPlayerStorage().getCharacterByName(pc.getName());
                            if (other != null) {
                                other.addHP((int) (player.getStat().getCurrentMaxHp() * SkillFactory.getSkill(主教.光芒飞箭).getEffect(player.getSkillLevel(主教.光芒飞箭)).getX() / 100.0D * 10));
                            }
                        }
                    }
                }
                //消耗MP500，以1000%的伤害最多对15个敌人造成8次攻击。同时向周围队员发放无视一次HP变成0的增益。
                //冷却时间90秒
                //获得增益的队员在600秒内不会再次获得天堂之门的增益。
                else if (skillid == 主教.天堂之门) {
                    MapleStatEffect tmpEffect = SkillFactory.getSkill(主教.天堂之门).getEffect(player.getSkillLevel(主教.天堂之门));
                    tmpEffect.applyTo(player);
                }
                break;
            case MapleJobCode.侠盗: {
                //处理激活刀飞幸运钱的再次使用
                if (isCritDamage && player.getSkillLevel(侠盗.幸运钱) > 0) {
                    player.switchLuckyMoney(true);
                }
            }
            case MapleJobCode.拳手:
            case MapleJobCode.斗士:
            case MapleJobCode.冲锋队长:
                if (!specialStats.isEnergyFull()) {
                    player.handleEnergyCharge(mobCount * 2);
                } else {
                    player.handleEnergyConsume(mobCount, skillid);
                }
                break;
            case MapleJobCode.剑客:
            case MapleJobCode.勇士:
            case MapleJobCode.英雄:
            case MapleJobCode.幻影3转: //添加幻影职业 幻影复制技能后有这个
            case MapleJobCode.幻影4转: //添加幻影职业 幻影复制技能后有这个
                if (skillid != 英雄.虎咆哮 && player.getBuffedValue(MapleBuffStat.斗气集中) != null) {
                    player.handleOrbgain(false);
                }
                break;
            case MapleJobCode.狂龙战士1转:
            case MapleJobCode.狂龙战士2转:
            case MapleJobCode.狂龙战士3转:
            case MapleJobCode.狂龙战士4转:
                int amon = 0;
                switch (skillid) {
                    case 狂龙战士.扇击:
                    case 狂龙战士.扇击_变身:
                        amon = 1;
                        break;
                    case 狂龙战士.飞龙斩_2:
                    case 狂龙战士.烈火箭:
                        amon = 2;
                        break;
                    case 狂龙战士.冲击波:
                    case 狂龙战士.穿刺冲击:
                        amon = 3;
                        break;
                    case 狂龙战士.牵引锁链:
                    case 狂龙战士.怒雷屠龙斩:
                    case 狂龙战士.天空剑影:
                    case 狂龙战士.剑气突袭:
                        amon = 5;
                        break;
                    case 狂龙战士.剑刃之壁:
                    case 狂龙战士.进阶剑刃之壁:
                        amon = 20;
                        break;
                    case 狂龙战士.恶魔之息:
                        amon = 40;
                        break;
                }
                if (amon > 0) {
                    player.handleMorphCharge(amon);
                }
                break;
            case MapleJobCode.神射手: {
                if (player.getBuffSource(MapleBuffStat.SECONDARY_STAT_IndieQrPointTerm) == 神射手.箭雨) {
                    Optional.ofNullable(SkillFactory.getSkill(神射手.箭雨)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(神射手.箭雨);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is神射手(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getX() * 1000));
                            player.send(MaplePacketCreator.userBonusAttackRequest(神射手.箭雨_1, 0, Collections.emptyList()));
                        }
                    });
                }
                break;
            }
            case MapleJobCode.魂骑士4转: {
                if (player.getBuffSource(MapleBuffStat.SECONDARY_STAT_IndieQrPointTerm) == 魂骑士.天人之舞) {
                    Optional.ofNullable(SkillFactory.getSkill(魂骑士.天人之舞)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(魂骑士.天人之舞);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        int value = player.getBuffedIntValue(MapleBuffStat.月光转换);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is魂骑士(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getX() * 1000));
                            player.send(MaplePacketCreator.userBonusAttackRequest(value == 1 ? 魂骑士.天人之舞_1 : 魂骑士.天人之舞_2, 0, Collections.emptyList()));
                        }
                    });
                }
                break;
            }
            case MapleJobCode.战神4转: {
                if (player.getBuffSource(MapleBuffStat.SECONDARY_STAT_IndieQrPointTerm) == 战神.装备摩诃) {
                    Optional.ofNullable(SkillFactory.getSkill(战神.装备摩诃)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(战神.装备摩诃);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is战神(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getX() * 1000));
                            player.send(MaplePacketCreator.userBonusAttackRequest(战神.装备摩诃_1, 0, Collections.emptyList()));
                        }
                    });
                }
                break;
            }
            case MapleJobCode.双弩精灵4转: {
                if (player.getBuffSource(MapleBuffStat.SECONDARY_STAT_IndieQrPointTerm) == 双弩.精灵元素) {
                    Optional.ofNullable(SkillFactory.getSkill(双弩.元素幽灵_3)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(双弩.精灵元素);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is双弩精灵(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getX() * 1000));
                            player.send(MaplePacketCreator.userBonusAttackRequest(双弩.元素幽灵_3, 0, Collections.emptyList()));
                        }
                    });
                }
                break;
            }
            case MapleJobCode.爆莉萌天使1转:
            case MapleJobCode.爆莉萌天使2转:
            case MapleJobCode.爆莉萌天使3转:
            case MapleJobCode.爆莉萌天使4转: {
//                ArrayList<Integer> monsterids = new ArrayList<>();
//                Skill skill = SkillFactory.getSkill(skillid);
//                MapleStatEffect effect = skill.getEffect(player.getTotalSkillLevel(SkillConstants.getLinkedAttackSkill(skillid)));
//                if (skill != null && effect != null && skillid != 爆莉萌天使.灵魂吸取_攻击 && skillid != 爆莉萌天使.灵魂吸取专家_1 && l3 - player.getstifftime() > 1500 && player.getStatForBuff(MapleBuffStat.灵魂吸取专家) != null && (effect = player.getStatForBuff(MapleBuffStat.灵魂吸取专家)).lH()) {
//                    player.setstifftime(l3);
//                    List<MapleMapObject> monstersInRange = player.getMap().getMonstersInRange(player.getTruePosition(), 100000.0);
//                    if (!monstersInRange.isEmpty()) {
//                        monstersInRange.forEach(mapleMapObject -> {
//                            if (mapleMapObject != null && !((MapleMonster) mapleMapObject).getStats().isFriendly()) {
//                                monsterids.add(mapleMapObject.getObjectId());
//                            }
//                        });
//                        new MapleForce(player.getId(), skillid, 0, MapleForceType.)
//                        player.send_other(i.b.x.a(player, 0, monsterids, 1, effect.kA(), 爆莉萌天使.灵魂吸取专家_1, 300, false), true);
//                        player.sendEnableActions();
//                    }
//                }
//                MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.伤害置换);
//                if (statForBuff != null) {
//                    long l4 = (long) player.getBuffedValue(MapleBuffStat.伤害置换) + l2 * (long)statForBuff.getY() / 100;
//                    player.setBuffedValue(MapleBuffStat.伤害置换, (int)Math.min(Math.max(0, l4), (long)Math.min(99999, player.getStat().getMaxHp())));
//                    player.updateBuffEffect(statForBuff, Collections.singletonMap(MapleBuffStat.伤害置换, (int)l4));
//                }
                if (skillid == 爆莉萌天使.爱星能量) {
                    Skill skill;
                    MapleStatEffect effect;
                    if ((skill = SkillFactory.getSkill(爆莉萌天使.爱星能量)) != null
                            && (effect = skill.getEffect(player.getTotalSkillLevel(skill))) != null) {
                        player.cancelEffectFromBuffStat(MapleBuffStat.爱星能量);
                        player.handle无敌(effect, effect.getZ());
                    }
                }
                break;
            }
            case MapleJobCode.船长:
                Integer value = player.getBuffedValue(MapleBuffStat.神速衔接);
                if (value == null) {
                    int skilllevel = player.getTotalSkillLevel(船长.神速衔接);
                    Optional.ofNullable(SkillFactory.getSkill(船长.神速衔接)).ifPresent(skill -> {
                        MapleStatEffect effect = skill.getEffect(skilllevel);
                        if (Randomizer.nextInt(100) < effect.getProp()) {
                            effect.applyTo(player);
                        }
                    });
                } else if (value > 1) {
                    player.cancelBuffStats(MapleBuffStat.神速衔接);
                }
                break;
            case MapleJobCode.尖兵新手:
            case MapleJobCode.尖兵1转:
            case MapleJobCode.尖兵2转:
            case MapleJobCode.尖兵3转:
            case MapleJobCode.尖兵4转:
                if (player.getBuffedValue(MapleBuffStat.精准火箭) != null) {
                    player.handleCardStack(skillid);
                }
                break;
            case MapleJobCode.风灵使者1转:
            case MapleJobCode.风灵使者2转:
            case MapleJobCode.风灵使者3转:
            case MapleJobCode.风灵使者4转:
                if (player.getBuffedValue(MapleBuffStat.狂风肆虐) != null) {
                    player.handle狂风肆虐(skillid);
                }

                break;
            case MapleJobCode.夜光:
            case MapleJobCode.夜光1转:
            case MapleJobCode.夜光2转:
            case MapleJobCode.夜光3转:
            case MapleJobCode.夜光4转:
                player.handleLuminous(skillid); //夜光光暗点数处理
                if (player.getJob() == 2712) {
                    player.handleDarkCrescendo(); //夜光黑暗高潮处理
                }
                player.handleBlackBless(); //夜光黑暗祝福处理
                break;
            case MapleJobCode.恶魔复仇者1转:
            case MapleJobCode.恶魔复仇者2转:
            case MapleJobCode.恶魔复仇者3转:
            case MapleJobCode.恶魔复仇者4转:
                player.handle超越状态(skillid);
                break;
            case MapleJobCode.箭神:
                // 真狙击
                // 消耗魔量 1000，发射最多对12个敌人以980%的伤害造成14次爆击攻击的箭矢，最多发射6次
                //越是接近瞄准镜中央，伤害即会提高15%，最多提高100%，额外无视100%怪物防御率
                //最多可在12秒内瞄准，在该时间内，以及在技能结束后的2秒内无敌
                //冷却时间 180秒
                if (skillid == 箭神.真一击要害箭 && JobConstants.is箭神(player.getJob()) && player.getBuffSource(MapleBuffStat.SECONDARY_STAT_CursorSniping) == 箭神.真狙击) {
                    int maxValue = Math.max(0, player.getBuffedIntValue(MapleBuffStat.SECONDARY_STAT_CursorSniping) - 1);
                    if (maxValue > 0) {
                        player.setBuffedValue(MapleBuffStat.SECONDARY_STAT_CursorSniping, maxValue);
                        player.updateBuffEffect(player.getStatForBuff(MapleBuffStat.SECONDARY_STAT_CursorSniping), Collections.singletonMap(MapleBuffStat.SECONDARY_STAT_CursorSniping, maxValue));
                    } else {
                        Optional.ofNullable(SkillFactory.getSkill(箭神.真狙击)).ifPresent(skill -> {
                            MapleStatEffect effect = skill.getEffect(player.getTotalSkillLevel(箭神.真狙击));
                            player.cancelEffectFromBuffStat(MapleBuffStat.SECONDARY_STAT_CursorSniping);
                            player.handle无敌(effect, 2000);
                        });
                    }
                }
                break;
            default:
                if (!player.isIntern()) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.潜入状态);
                    MapleStatEffect ds = player.getStatForBuff(MapleBuffStat.隐身术);
                    if (ds != null) {
                        if (ds.getSourceid() != 双刀.进阶隐身术 || !ds.makeChanceResult()) {
                            player.cancelEffectFromBuffStat(MapleBuffStat.隐身术);
                        }
                    }
                }
        }

        // 控制职业群
        if (JobConstants.is战士(player.getJob()) && player.getBuffedIntValue(MapleBuffStat.SECONDARY_STAT_IndieQrPointTerm) > 0 && player.getBuffSource(MapleBuffStat.SECONDARY_STAT_IndieQrPointTerm) == 战士.灵气武器) {
            Optional.ofNullable(SkillFactory.getSkill(战士.灵气武器)).ifPresent(skill -> {
                int totalSkillLevel = player.getTotalSkillLevel(战士.灵气武器);
                MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                if (totalSkillLevel > 0 && effect != null && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                    player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getZ() * 1000));
                    player.send(MaplePacketCreator.userBonusAttackRequest(战士.灵气武器_1, 0, Collections.emptyList()));
                }
            });
        }

    }

}
